﻿@model CodeNotes.Model.CW_Article

@{
    ViewBag.Title = "ArticleEdit";
    List<CW_TagView> tagList = ViewBag.tagList;
}
@section Head{
    <style>
    </style>
}
<h2 class="page-header">ArticleEdit</h2>
<div>
    @Html.ActionLink("Back to List", "ArticleList", null, new { Class = "btn btn-default" })
</div>
<hr />

@using (Html.BeginForm("ArticleEdit", "Admin", FormMethod.Post, new { id = "form1", Class = "from", onsubmit = "return checkInput();", enctype = "multipart/form-data" }))
{
    <input type="hidden" name="ArticleId" value="@Model.ArticleId" />
    <input type="hidden" name="Thumb" value="@Model.Thumb">
    <input type="hidden" name="CreateDate" value="@Model.CreateDate">
    <input type="hidden" name="PV" value="@Model.PV">
    <input type="hidden" name="LikeCount" value="@Model.LikeCount">
    <input type="hidden" name="CommentCount" value="@Model.CommentCount">
    <div class="form-group">
        <label>标题</label>
        <input type="text" class="form-control" name="Title" value="@Model.Title" data-rule-required='true' data-msg-required="请输入展品介绍">
    </div>
    <div class="form-group">
        <label>作者</label>
        <input type="text" class="form-control" name="Author" value="@Model.Author" data-rule-required='true' data-msg-required="请输入展品介绍">
    </div>
    <div class="form-group">
        <label>简介</label>
        <input type="text" class="form-control" name="Abstract" value="@Model.Abstract" data-rule-required='true' data-msg-required="请输入展品介绍">
    </div>
    <div class="form-group">
        <label>内容</label>
        <textarea id="editor" rows="5" name="Content" data-rule-required='true' data-msg-required="请输入展品介绍">@Model.Content</textarea>
    </div>
    <div class="form-group">
        <label>logo</label>
        <input type="file" name="thumbnail" id="thumbnail" />
        @if (!string.IsNullOrEmpty(Model.Thumb))
        {
            <img style="max-height:220px;" src="@Url.Content("/images/logo/" + Model.Thumb)" />
        }
    </div>
 
    <div class="form-group">
        <label>标签</label>
        <div class="checkbox">
            @foreach (CW_TagView p in tagList)
            {
                <label class="checkbox-inline">
                    @if (p.IsRelate)
                    {
                        <input type="checkbox" name="TagId" checked value="@p.Tag.TagId" />@p.Tag.TagName
                    }
                    else
                    {
                        <input type="checkbox" name="TagId" value="@p.Tag.TagId" />@p.Tag.TagName
                    }
                    
                </label>
            }
        </div>
    </div>
    <div class="form-group">
        <div class="checkbox">
            <label>
                @if (Model.IsShow)
                {
                    <input type="checkbox" name="IsShow" value="true" checked="checked">
                }
                else
                {
                    <input type="checkbox" name="IsShow" value="true">
                }
                发布
            </label>
        </div>
    </div>
    <button type="submit" class="btn btn-default">Submit</button>
}

@section Scripts {
    <script src="~/UEditor/ueditor.config.js"></script>
    <script src="~/UEditor/ueditor.all.min.js"></script>
    <script src="~/UEditor/lang/zh-cn/zh-cn.js"></script>
    <script type="text/javascript">
        //实例化编辑器
        //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
        var ue = UE.getEditor('editor');
    </script>

    <script src="~/scripts/jquery.validate.min.js"></script>
    <script>
        $(function () {
            validateCN();
        })
        function validateCN() {
            $("form").validate({
                errorClass: "text-danger text-sm",
                errorPlacement: function (error, element) {
                    element.after(error);
                }
            });
        }
        function checkInput() {
            return $("#form1").valid();
        }
    </script>
}
